local skel = fk.CreateSkill {
  name = "emo__yanzhi",
  tags = {Skill.Wake},
}

skel:addEffect(fk.TurnEnd, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return player:usedSkillTimes(skel.name, Player.HistoryGame) == 0 and player:hasSkill(skel.name)
  end,
  can_wake = function(self, event, target, player, data)
    return #player.room.logic:getEventsOfScope(GameEvent.Dying, 1, function(e)
      local dying = e.data
      return dying.who ~= player and dying.damage and dying.damage.from == player
    end, Player.HistoryTurn) > 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:changeMaxHp(player, -1)
    if player.dead then return end
    player:drawCards(3, skel.name)
    room:handleAddLoseSkills(player, "emo__lianpian")
  end,
})

skel:addEffect(fk.EnterDying, {
  anim_type = "negative",
  can_trigger = function(self, event, target, player, data)
    return player:usedSkillTimes(skel.name, Player.HistoryGame) == 0 and player:hasSkill(skel.name) and player == target
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:changeMaxHp(player, -1)
    if player.dead then return end
    room:recover({ who = player, num = player.maxHp - player.hp, recoverBy = player, skillName = skel.name })
    room:handleAddLoseSkills(player, "-emo__yanzhi")
  end,
})


Fk:loadTranslationTable{
  ["emo__yanzhi"] = "燕志",
  [":emo__yanzhi"] = "①觉醒技，任意回合结束时，若你本回合造成其他角色进入过濒死状态，你扣减1点体力上限，摸三张牌，获得技能〖连翩〗。②当你进入濒死状态时，若你未发动〖燕志〗，你扣减1点体力上限，将体力回复至体力上限，然后失去〖燕志〗。",
}

return skel
